import { h, resolveComponent } from "vue";
import { createRouter, createWebHistory } from "vue-router";

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: "/01news",
      component: { render() { return h(resolveComponent('router-view')) } }, // resolveComponent解析router-view组件，vue3中的h函不能直接接收字符串
      redirect: "/01news/news",
      children: [
        {
          path: "news",
          name: "xinwen",
          component: () => import('@/views/01News/News.vue')
        },
        {
          path: "about/:title/:content?",
          name: "guanyv",
          component: () => import('@/views/01News/About.vue')
        },
      ]
    },
    {
      path: "/news",
      component: () => import('@/views/01News/News.vue')
    }
  ],
  // scrollBehavior: () => ({ left: 0, top: 0 })  // 路由调整后，页面滚动到顶部
})

export default router
